#include "tree.h"
#include <iostream>
#include <string>

using namespace std;

int  main()
{
    string str;
    char *p;
    int length, i;
    BinaryTree BiTree;

    cout<<"请输入前序表达式序列: -+*a##b##c##a#*b+##c##\n";
    cout <<"(其中#号表示空叶子节点，需要和表达式的数字一致)\n"; 
    //cin >>str;
    str ="-+*a##b##c##*a##+b##c##";
    p = &str[0];
    i = 0;

    BiTree.create(BiTree.root, p); 

    //校验根结点右子树的右枝
    BinaryTreeNode *tmpPointer = BiTree.root;
    
    cout <<"校验右子树右枝: ";
    while(tmpPointer->rightchild != NULL){
      cout << tmpPointer->rightchild->data;
      tmpPointer = tmpPointer->rightchild;
      if(tmpPointer->leftchild !=NULL){
         //  cout <<" "<<tmpPointer->leftchild->data<<"\n";
      }
    }
    //cout <<BiTree.root->rightchild->data<<"test";
    cout <<"\n\n";

    //中序遍历
    cout <<"中缀表达式:";
    BiTree.inOrder();

    return 0;
}
